﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.MicroKernel.Registration;
using DynCMS.NET.DataAccess.Implementation;

namespace DynCMS.NET.DataAccess.IOC
{
    public class Installer : Castle.MicroKernel.Registration.IWindsorInstaller
    {
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            container.Register(
                Classes.FromThisAssembly()
                .Where(type => type == typeof(DataContext))
                .WithServiceSelf()
                .LifestylePerWebRequest());

            container.Register(
                Classes.FromThisAssembly()
                .Where(type => type.Name.EndsWith("Repository", StringComparison.InvariantCultureIgnoreCase))
                .WithService
                .AllInterfaces()
                .LifestylePerWebRequest());
        }
    }
}